package com.neuedu.shop.entity;

import com.baomidou.mybatisplus.annotations.*;
import com.baomidou.mybatisplus.enums.IdType;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.activerecord.Model;

import java.io.Serializable;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author Qin
 * @since 2021-04-10
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_product")
public class Product extends Model<Product> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 商品名称
     */
    private String productName;
    /**
     * 商品描述
     */
    private String productDescription;
    /**
     * 普通价格
     */
    private BigDecimal productNormalPrice;
    /**
     * 会员价格（为普通价格的八折）
     */
    private BigDecimal productMemberPrice;
    /**
     * 商品图片路径
     */
    private String productImgpath;
    /**
     * 商品上架时间
     */
    private Timestamp productCreateTime;
    /**
     * 商品类别id（新添加商品必须有类别，商品类别id必须为三级）
     */
    private Integer productCategoryid;
    @TableField(exist = false)
    private Category category;
    /**
     * 商品更新时间
     */
    private Timestamp productUpdateTime;

    public Product(String productName, String productDescription, BigDecimal productNormalPrice, String productImgpath, Integer productCategoryid) {
        this.productName = productName;
        this.productDescription = productDescription;
        this.productNormalPrice = productNormalPrice;
        this.productMemberPrice = productNormalPrice.multiply(BigDecimal.valueOf(0.8));
        this.productImgpath = productImgpath;
        this.productCategoryid = productCategoryid;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
